<?php
/**
 * main order panel
 */
class order_main extends CI_Controller{
	/**
	 * load default models and save them to $this without model suffix
	 */
	public function __construct()
	{
		parent::__construct();
		$this->load->model('store_model', 'store');
        $this->load->model('food_category_model', 'food_category');
        $this->load->model('food_model', 'food');
  }
	/**
	 * load store information and displays it
	 */
	public function index()
	{
		$store = $this->store->get_store_info();
        // get things that not gonna change during order operation here, get other info through AJAX
        $food_category = $this->food_category->get_category();
        $first_food_category = current($food_category);

        //$food_option_scope_all = $this->food_option->etc();

		$data = array(
					'page_title' => 'main order panel',
					'page_css'   => array('order.css'),
					'page_js'    => array('order-main.js'),
					'store'     => $store,
                    'food_category'   => $food_category,
                    'food_category_select' => $first_food_category['id']
		);

		$this->load->view('order/main', $data);
	}

    /**
     * retrieve information when food category is changed
     *
     */
    public function change_food_category(){
        $food_category_id = $this->input->post('food_category_id');
        $foods = $this->food->get_food($food_category_id);
        echo json_encode($foods);
    }
}

/* End of file store_config.php */
/* Location: ./system/application/controllers/admin/store_config.php */
